<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Symbol 创建对象属性</title>
</head>
<body>
    <script>
        //向对象中添加方法 up down
        let game ={
            name:'俄罗斯方块',
            up:function(){
                console.log(上);
            },
            down:function(){
                console.console(下);
            }
        }

        // 声明一个对象
        let methods ={
            up:Symbol(),
            down: Symbol()
        }

        game[methods.up] = ()=> console.log('1');
        game[methods.down] = ()=> console.log('2');

        console.log(game);
        

        let youxi ={
            name:'狼人杀',
            [Symbol('say')]:function(){
                console.log("我可以发言")
            },
            [Symbol('zibao')]:function(){
                console.log('我可以自爆');
            }

        }

        //调用
        //方法一
        const langrensha = Object.getOwnPropertySymbols(youxi);
        console.log(langrensha);
        youxi[langrensha[0]]();
        
        //方法二
        const lrs = Reflect.ownKeys(youxi);
        console.log(lrs);
        youxi[lrs[1]]();
            
    </script>
</body>
</html>